import asyncio
from f2.apps.tiktok.handler import TiktokHandler
from f2.apps.tiktok.utils import SecUserIdFetcher


kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
        "Referer": "https://www.tiktok.com/",
    },
    "proxies": {"http://": None, "https://": None},
    "timeout": 10,
    "cookie": "tt_chain_token=9AOUrwQv/h2/zLiiLto2Dg==; tiktok_webapp_theme=light; delay_guest_mode_vid=5; _ttp=32BJzVGy0aKRBjG1hMlZH4mZYPv; tt_csrf_token=wrrlcJ0z-yQscPxBZ5U22N0mOJhRVHGF165M; perf_feed_cache={%22expireTimestamp%22:1758355200000%2C%22itemIds%22:[%227543156445152382224%22%2C%227520945406226812216%22%2C%227544614856301972737%22]}; msToken=Un9ZfgZR8El_gZkjCF6qGMwTsWYfDNXsKRbUib1bmBTgnxC6D7zxhNSusUqPYwtx5pxyvv7xZa59aJtcJ_4oRFYRlSSGPv5uDZgYxvaAba3hXUAxBV9PyefknKcpZMYSLZi3Spx3lzKb-SOfh1A4s3mT; passport_csrf_token=60b07caafd1671e50ecaf77ec6cd5468; passport_csrf_token_default=60b07caafd1671e50ecaf77ec6cd5468; s_v_web_id=verify_mfp53d3y_TKH3aLuh_TMSE_4YJx_B4q3_gcQTDTsVnUr8; multi_sids=7452166430978065425%3A0618f18096fa2d541d5f9f5b5f5d4333; cmpl_token=AgQQAPP_F-RO0rdVh0U1ux0o8vXu0A9LP5IhYNy55w; passport_auth_status=0a6b20189ec0a01a9c18731fd661e0c5%2C; passport_auth_status_ss=0a6b20189ec0a01a9c18731fd661e0c5%2C; sid_guard=0618f18096fa2d541d5f9f5b5f5d4333%7C1758183552%7C15552000%7CTue%2C+17-Mar-2026+08%3A19%3A12+GMT; uid_tt=b875b2cb8e53bbcdac6ec6632d6510488f6f169fae89602b6e85f49ac1e14edd; uid_tt_ss=b875b2cb8e53bbcdac6ec6632d6510488f6f169fae89602b6e85f49ac1e14edd; sid_tt=0618f18096fa2d541d5f9f5b5f5d4333; sessionid=0618f18096fa2d541d5f9f5b5f5d4333; sessionid_ss=0618f18096fa2d541d5f9f5b5f5d4333; sid_ucp_v1=1.0.0-KGQ5YzdlNzRmZjkzNThlOTNmMmZlZGQ0NjFlMmZjNzA3NDgxMWQwYTIKGQiRiKfsq7zatWcQgIGvxgYYsws4CEASSAQQAxoCbXkiIDA2MThmMTgwOTZmYTJkNTQxZDVmOWY1YjVmNWQ0MzMz; ssid_ucp_v1=1.0.0-KGQ5YzdlNzRmZjkzNThlOTNmMmZlZGQ0NjFlMmZjNzA3NDgxMWQwYTIKGQiRiKfsq7zatWcQgIGvxgYYsws4CEASSAQQAxoCbXkiIDA2MThmMTgwOTZmYTJkNTQxZDVmOWY1YjVmNWQ0MzMz; store-idc=alisg; store-country-code=au; store-country-code-src=uid; tt-target-idc=alisg; tt-target-idc-sign=eGnx1_2hs4JFB7zc-5uUcwhsoaZwS6IKOO08PK2dQyVFnEbG6ZrntkOwlGRUUz5ZD_fBe0vJDZ7NKsMWnF8kQD_3QOjRgjgPZ6jOG_UA2Qph-qMoLOTb5v4aBXlfsqzg8BGoQIkka5gVT4E2kVgJFAwCXtDpvzdfAkzIE7ruGcVjMVTTzrn0pFViKEwrQJJM9ajwbID1n5XlUtBOiFKa4uuVujJDBr1fPyj0RwHLB1LYjtG-srtLO3Sa84UoOAgyxBb6Hfv9KD4La3i4akyucuiSltBp6_KQRLRdAaHEoDMw3TQ3tBecEMaIZ83S6amiA1P11O96FMA2Pv7Cay0Z2Hu7J71izi485sCoPBL_ViQYLJsTjvSom7IP2Ef2VHZWPsdXmMkkANT02Bf2bxLj5IOgb1ds5D9KH2x33R4LqWj4UjrcdyZ-5wu8V3LMhNEwkPBF-pZC3-BKB_uePtgqWZwkYqA2xJMU59pJDYqaJ9LYTrk7QSRHZsemUPEiHrBv; last_login_method=google; store-country-sign=MEIEDIMddU-pHMfHw5E8vQQgI8CUn0Q7os2crCHZwCdKaqL5ZPJclf0CEc2viy86LmMEENpFH4nK8uufzM5_Pb8en0E; tiktok_webapp_theme_source=auto; ttwid=1%7CoFppuvJXQRJ24Syt3RPjRfY6xhfKhB1V81YK23IHhXg%7C1758183555%7C82d5dea30b21ce723b20333c160112bd73cc3e61df1bbc7d7d000cdd8b64143f; odin_tt=7b0b9b880fe8b58839b92a5fb82bd9e91faa5e1a0e536f053599a300026f9dd7f32597fed4436d0c35a38aa4f388219cf2188fb35a6408eb10e69de06e85bff2ef8f2073cd32057e6ddd68a0435709ce; msToken=WePJRdKrdIgU_hx1TDBQ_fTwoFmORgodL-GR4--17b2AenQ11B9mvBNE-cEKaCTYmK9QhkV13WgC1vYhHB7QoyxMH4fV8m8gPo20EAzJ9vIlB4_oIxbmUF8o0OMB_o6gXbBS1tdUTJlDpfB8t0PjdZPZ; passport_fe_beating_status=true",
}


async def main():
    secUid = await SecUserIdFetcher.get_secuid("https://www.tiktok.com/@vantoan___")

    async for aweme_data_list in TiktokHandler(kwargs).fetch_user_post_videos(
        secUid, 0, 0, 10, 20
    ):
        print("=================_to_raw================")
        print(aweme_data_list._to_raw())
        # print("=================_to_dict===============")
        # print(aweme_data_list._to_dict())
        # print("=================_to_list===============")
        # print(aweme_data_list._to_list())


if __name__ == "__main__":
    asyncio.run(main())
